#ifndef QRSCSERVERTHREAD_H
#define QRSCSERVERTHREAD_H

#include <QObject>
#include <QWidget>
#include <QThread>
#include "qrscserver.h"
class QRSCServerThread : public QObject
{
    Q_OBJECT
public:
    explicit QRSCServerThread(QObject *parent = nullptr);
    ~QRSCServerThread();
    bool startServer(quint16 port = 0);
    void stopServer();
    void sendData(qintptr socketDescriptor, const QByteArray &data);
    void disconnectClient(qintptr socketDescriptor);
    void setQuality(int quality){this->quality = quality;}
    int serverPort(){return server->getPort();}
signals:
    void serverStarted(quint16 port);
    void serverStopped();
    void dataReceived(qintptr socketDescriptor, const QByteArray &data);
    void clientConnected(qintptr socketDescriptor);
    void clientDisconnected(qintptr socketDescriptor);
    void serverError(const QString &errorString);

private:
    QThread* thread;
    QRSCServer* server;
    int quality;
};

#endif // QRSCSERVERTHREAD_H
